#region Using Directives

using System;
using Microsoft.Practices.ComponentModel;
using Microsoft.Practices.RecipeFramework;

using EnvDTE;
using EnvDTE80;

#endregion

namespace EEst.SoftwareFactory.Actions
{
    /// <summary>
    /// the action to configure Makefile.xc and XCConfig.xml
    /// </summary>
    class AppProjectPolicyAction : Action
    {
        #region Input Properties

        [Input]
        public string ProjectName
        {
            get { return projectName; }
            set { projectName = value; }
        } string projectName;

        [Input]
        public string ProjectType
        {
            get { return projectType; }
            set { projectType = value; }
        } string projectType;

        [Input(Required=false)]
        public string ClassType
        {
            get { return classType; }
            set { classType = value; }
        } string classType;
        #endregion
        

        #region Output Properties

        [Output]
        public string SourceFileName
        {
            get { return sourceFileName; }
            set { sourceFileName = value; }
        } string sourceFileName;

        [Output]
        public string HeaderFileName
        {
            get { return headerFileName; }
            set { headerFileName = value; }
        } string headerFileName;

        [Output]
        public string ClassName
        {
            get { return className; }
            set { className = value; }
        } string className;

        [Output]
        public string BlackBoardFileName
        {
            get { return bbName; }
            set { bbName = value; }
        }
        string bbName;

        #endregion

        #region IAction Members

        public override void Execute()
        {
            if (projectType.CompareTo("Strategy") == 0)
            {
                className = ProjectName + "Strategy";
            }
            else if (projectType.CompareTo("DriveControl") == 0)
            {
                className = ProjectName + "DriveControl";
                bbName = ProjectName + "DCBlackBoard.h";
            }
            else if (projectType.CompareTo("PathRecognizer") == 0)
            {
                className = ProjectName + "PathRecognizer";
                bbName = ProjectName + "PRBlackBoard.h";
            }
            else if (projectType.CompareTo("Application") == 0)
            {
                if (classType.CompareTo("InitApp")==0)
                {
                    className = ProjectName + "InitApp";
                }
                else if (classType.CompareTo("TermApp")==0)
                {
                    className = ProjectName + "TermApp";
                }
                else if (classType.CompareTo("RunApp")==0)
                {
                    className = ProjectName + "RunApp";
                }
                else if (classType.CompareTo("AppState")==0)
                {
                    className = ProjectName + "AppState";
                }
            }
            headerFileName = className + ".h";
            sourceFileName = className + ".cpp";
        }

        public override void Undo()
        {
//            throw new Exception("The method or operation is not implemented.");
        }

        #endregion
    }
}
